#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@author:hengk
@contact: hengk@foxmail.com
@datetime:2019-10-25 15:24
"""

#!/usr/env/bin python3
import argparse
import os


def parse_args():
    parser = argparse.ArgumentParser()

    parser.add_argument('--num_img', type=int, default=100, help="产生图片的数量")

    parser.add_argument('--max_length', type=int, default=10,help='条码的最长长度')

    parser.add_argument('--config_file', type=str, default='./configs/default.yaml',
                        help='Set the parameters when rendering images')

    parser.add_argument('--min_length', type=int, default=8,help='条码的最小长度')

    parser.add_argument('--img_height', type=int, default=64)
    parser.add_argument('--img_width', type=int, default=320,help="If 0, output images will have different width")

    parser.add_argument('--bg_dir', type=str, default='./data/bg',
                        help="Some text images(according to your config in yaml file) will"
                             "use pictures in this folder as background")
    parser.add_argument('--corpus_dir', type=str, default="./data/corpus",
                        help='When corpus_mode is chn or eng, text on image will randomly selected from corpus.'
                             'Recursively find all txt file in corpus_dir')

    parser.add_argument('--output_dir', type=str, default='./output', help='Images save dir')

    parser.add_argument('--images_dir', type=str, default='default', help='output images are saved under output_dir/{tag} dir')

    parser.add_argument('--debug', action='store_true', default=False, help="output uncroped image")

    parser.add_argument('--num_processes', type=int, default=None,
                        help="使用多个处理器生成图片，如果为None，使用所有cpu")

    flags, _ = parser.parse_known_args()


    if os.path.exists(flags.bg_dir):
        num_bg = len(os.listdir(flags.bg_dir))
        flags.num_bg = num_bg



    if flags.num_processes == 1:
        parser.error("num_processes min value is 2")

    return flags


if __name__ == '__main__':
    args = parse_args()
